;
const account_set_ops = {
    init () {
        this.eventBind();
    },
    eventBind () {
        $(".wrap_account_set .save").click(function() {
            let btn_target = $(this);
            if (btn_target.hasClass('disabled')) {
                common_ops.alert("正在处理提交中")
                return;
            }
            const nickname_target = $(".wrap_account_set input[name=nickname]");
            const nickname = nickname_target.val();

            const email_target = $(".wrap_account_set input[name=email]");
            const email = email_target.val();

            const mobile_target = $(".wrap_account_set input[name=mobile]");
            const mobile = mobile_target.val();

            const login_name_target = $(".wrap_account_set input[name=login_name]");
            const login_name = login_name_target.val();

            const login_pwd_target = $(".wrap_account_set input[name=login_pwd]");
            const login_pwd = login_pwd_target.val();

            if (!nickname || nickname.length < 2) {
                common_ops.tip("请输入符合规范的姓名！！", nickname_target)
                return false;
            }
           if (!email || email.length < 2) {
                common_ops.tip("请输入符合规范的邮箱！！", email_target)
                return false;
           }

           if (!mobile || mobile.length < 11) {
                common_ops.tip("请输入符合规范的手机号码！！", mobile_target)
                return false;
           }
           if (!login_name || login_name.length < 6) {
                common_ops.tip("请输入符合规范的手机号码！！", login_name_target)
                return false;
           }

           if (!login_pwd || login_pwd.length < 6) {
                common_ops.tip("请输入符合规范的手机号码！！", login_pwd_target)
                return false;
           }

            btn_target.addClass("disabled")
            const data = {
                nickname,
                email,
                mobile,
                login_name,
                login_pwd,
                id: $(".wrap_account_set input[name=id]").val()
            }
            $.ajax({
                url: common_ops.buildUrl("/account/set"),
                type: 'POST',
                data: data,
                dataType: 'json',
                success: function (res) {
                    btn_target.removeClass("disabled");
                    let callback = null;
                    if (res.code === 200) {
                        callback = function () {
                            window.location.href = common_ops.buildUrl("/account/index")
                        }
                    }
                    common_ops.alert(res.msg, callback);
                }
            })
        })
    }
}

$(document).ready(function () {
    account_set_ops.init()
})